import apis from "../../http/apis/apis"

export default {
    namespaced: true,
    state: {
        tableData: [
        ],
        currentPage: 1,
        pageSize: 5,
        total: 0,
        search: {
            content: "",
            date: "",
            state: "全部",
        },
    },
    mutations: {
        //改变每页显示条数
        changePageSize(state, pageSize) {
            state.pageSize = pageSize
        },
        //改变当前页
        changecurrentPage(state, currentPage) {
            state.currentPage = currentPage
        },
        setTableData(state,arr){
            state.tableData=arr
        },
        setTotal(state,data){
            state.total = data
        }
    },
    actions: {
        async getComplaints(context,msg){
            const {data} = await apis.complaints.getComplaints(msg)
            context.commit('setTableData',data.data.data)
            context.commit('setTotal',data.data.total)
        },
        async getComplaintsById(context,msg){
            const { data } = await apis.complaints.getComplaintsById(msg)
            return data
        },
        async minusTenantsCredits(context,msg){
            const { data }= await apis.complaints.minusTenantsCredits(msg)
            if(data.status){
                alert(data.message)
            }else{
                alert(data.message)
            }
        },
        async minusLessorsCredits(context,msg){
            const { data }= await apis.complaints.minusLessorsCredits(msg)
            if(data.status){
                alert(data.message)
            }else{
                alert(data.message)
            }
        },
        async handleComplaints(context,msg){
            const { data } = await apis.complaints.handleComplaints(msg)
            return data
        }
    },
}